package org.come.control;

import com.tool.role.RoleData;
import com.updateNew.MyIsif;
import org.come.Frame.MountJframe;
import org.come.Jpanel.ZhuJpanel;
import org.come.Jpanel.mountJPanel;
import org.come.MountShouHu.xuanzeJframe;
import org.come.action.FromServerAction;
import org.come.bean.MountResult;
import org.come.entity.Mount;
import org.come.entity.RoleSummoning;
import org.come.until.*;

import com.tool.image.ImageMixDeal;

import java.util.List;

public class MountFunctionControl implements FromServerAction {

	@Override
	public void controlMessFromServer(String mes, String type) {
		final MountResult mountResult = (MountResult)GsonUtil.getGsonUtil().getgson().fromJson(mes, MountResult.class);
		final mountJPanel mountJPanel = MountJframe.getMountjframe().getMountjpanel();
		UserMessUntil.setMountList(mountResult.getMounts());
		mountJPanel.getModelmount().removeAllElements();
		final List<RoleSummoning> pets = UserMessUntil.getPetListTable();
		try {
			if (mountResult.getMounts().size() != 0) {
				int index = -1;
				ZhuJpanel.getListMount().clear();
				int i = 0;
				while (i < mountResult.getMounts().size()) {
					final Mount mount = (Mount)mountResult.getMounts().get(i);
					ZhuJpanel.getListMount().add(mount);
					if (mount.getMountid().intValue() == ImageMixDeal.userimg.getRoleShow().getMount_id()) {
						index = i;
						mountJPanel.getModelmount().addElement("( * ) " + mount.getMountname());
					}
					else {
						mountJPanel.getModelmount().addElement(mount.getMountname());
					}
					++i;
				}
				if (index != -1) {
					mountJPanel.getListmount().setSelectedIndex(index);
					ExpIncreaseUntil.showMountValue((Mount)mountResult.getMounts().get(index));
					if (false) {//GameClientcaonimab.getClassic() == 1
						mountJPanel.getBtnRiding().setIcons(CutButtonImage.cuts("inkimg/hongmu/ss695.png"));
					}
					else {
						mountJPanel.getBtnRiding().setText("休息");
					}
				}
				else {
					if (false) {//GameClientcaonimab.getClassic() == 1
						mountJPanel.getBtnRiding().setIcons(CutButtonImage.cuts("inkimg/hongmu/ss694.png"));
					}
					else {
						mountJPanel.getBtnRiding().setText("骑乘");
					}
					mountJPanel.getListmount().setSelectedIndex(0);
					ExpIncreaseUntil.showMountValue((Mount)mountResult.getMounts().get(0));
				}
			}
			else {
				mountJPanel.getLabmountlevel().setText("");
				mountJPanel.getLabmounttili().setText("");
				mountJPanel.getLabmountintelligence().setText("");
				mountJPanel.getLabmountpower().setText("");
				mountJPanel.getLabmountRootbone().setText("");
				mountJPanel.getLabmountexp().setText("");
			}
			org.come.Jpanel.mountJPanel.showListModel(pets, RoleData.getRoleData().getLoginResult().getSummoning_id());
			/*if (GameClientcaonimab.getClassic() == 1) {
				SJpaneUntil.Mounn();
			}
			if (GameClientcaonimab.getClassic() == 2) {
				HJpaneUntil.Mount();
			}
			if (GameClientcaonimab.getClassic() == 3) {
				DJpaneUntil.Mounn();
			}*/
			try {
				String style = MyIsif.getStyle();
				if ("水墨UI".equals(style)) {
				mountJPanel.getShouhu().get(0).setIcons(CutButtonImage.cuts("inkImg/Client/选中按钮.png"));
				mountJPanel.getShouhu().get(1).setIcons(CutButtonImage.cuts("inkImg/Client/未选中按钮.png"));
				xuanzeJframe.getxuanzeJframe().getXuanzeJpanel().shoumount(mountResult.getMounts());
				} else {
					//
					mountJPanel.getShouhu().get(0).setIcons(CutButtonImage.cuts("inkImg/hongmu/未选中按钮(1).png"));
					mountJPanel.getShouhu().get(1).setIcons(CutButtonImage.cuts("inkImg/hongmu/未选中按钮(1).png"));
					xuanzeJframe.getxuanzeJframe().getXuanzeJpanel().shoumount(mountResult.getMounts());
				}
			} catch (Exception exception) {
				exception.printStackTrace();
			}
			FormsManagement.showForm(7);
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
